<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$member=$this->model('member')->checkmember('',true);
if($_RQ['op']=='main'){
	$return['setting']=$this->plugin_setting('page_setting');
	$params=array('mid'=>$_SESSION['uid']);
	$return['commission_money']=$this->sum('commission',$params,'money');
	if(!$return['commission_money']){
		$return['commission_money']=0;
	}
	$return['commission_total']=$this->count('commission',$params);
	$return['list']=array();
	$type=intval($_RQ['type']);
	$return['params']=array(
		'type'=>$type?:27,
		'page'=>1,
	);
	$return['psize']=20;
	set_html('title',$return['setting']['torder']?:'经销订单');
	$return['xuniname']=$this->xuniname;
	exi($return);
}
if($_RQ['op']=='list'){
	$params=array('mid'=>$_SESSION['uid']);
	$type=intval($_RQ['type']);
	if(!$type){
		$type=27;
	}
	$params['type']=$type;
	$return['params']['type']=$type;
	$psize=20;
	$pindex=intval($_RQ['page'])?:1;
	$parameter=array(
		'params'=>$params,
		'limit'=>array($pindex,$psize),
		'orderby'=>'id desc',
	);
	$list=$this->get_list('commission',$parameter);
	if(!$list){
		exi('none');
	}
	foreach($list as &$item){
		$order=$this->get('order',array('ordersn'=>$item['ordersn']));
		$item['member']=model('core/member')->basic($order['mid']);
		//$item['order']=$order;		
	}
	//exi('num'.count($list),'error');
	exi($list);
}
?>